import { RoutesAlias } from '../routesAlias'
import { AppRouteRecord } from '@/types/router'

/**
 * 菜单列表、异步路由
 *
 * 支持两种模式:
 * 前端静态配置 - 直接使用本文件中定义的路由配置
 * 后端动态配置 - 后端返回菜单数据，前端解析生成路由
 *
 * 菜单标题（title）:
 * 可以是 i18n 的 key，也可以是字符串，比如：'用户列表'
 *
 * RoutesAlias.Layout 指向的是布局组件，后端返回的菜单数据中，component 字段需要指向 /index/index
 * 路由元数据（meta）：异步路由在 asyncRoutes 中配置，静态路由在 staticRoutes 中配置
 */
export const asyncRoutes: AppRouteRecord[] = [
  {
    name: 'Dashboard',
    path: '/dashboard',
    component: RoutesAlias.Layout,
    meta: {
      title: 'menus.dashboard.title',
      icon: '&#xe721;',
      roles: ['R_SUPER', 'R_ADMIN']
    },
    children: [
      {
        path: 'console',
        name: 'Console',
        component: RoutesAlias.Dashboard,
        meta: {
          title: 'menus.dashboard.console',
          keepAlive: false,
          fixedTab: true
        }
      }
    ]
  },
  {
    path: '/system',
    name: 'System',
    component: RoutesAlias.Layout,
    meta: {
      title: 'menus.system.title',
      icon: '&#xe7b9;',
      roles: ['R_SUPER', 'R_ADMIN']
    },
    children: [
      {
        path: 'config',
        name: 'Configuration',
        component: RoutesAlias.Config,
        meta: {
          title: 'menus.system.config',
          keepAlive: true,
          roles: ['R_SUPER', 'R_ADMIN']
        }
      },
      {
        path: 'user',
        name: 'User',
        component: RoutesAlias.User,
        meta: {
          title: 'menus.system.user',
          keepAlive: true,
          roles: ['R_SUPER', 'R_ADMIN']
        }
      },
      {
        path: 'role',
        name: 'Role',
        component: RoutesAlias.Role,
        meta: {
          title: 'menus.system.role',
          keepAlive: true,
          roles: ['R_SUPER']
        }
      },
      {
        path: 'position',
        name: 'Position',
        component: RoutesAlias.Position,
        meta: {
          title: 'menus.system.position',
          keepAlive: true,
          roles: ['R_SUPER', 'R_ADMIN']
        }
      },
      {
        path: 'tag',
        name: 'Tag',
        component: RoutesAlias.Tag,
        meta: {
          title: 'menus.system.tag',
          keepAlive: true,
          roles: ['R_SUPER', 'R_ADMIN']
        }
      },
      {
        path: 'department',
        name: 'Department',
        component: RoutesAlias.Department,
        meta: {
          title: 'menus.system.department',
          keepAlive: true,
          roles: ['R_SUPER', 'R_ADMIN']
        }
      },
      {
        path: 'user-center',
        name: 'UserCenter',
        component: RoutesAlias.UserCenter,
        meta: {
          title: 'menus.system.userCenter',
          isHide: true,
          keepAlive: true,
          isHideTab: true
        }
      },
      {
        path: 'menu',
        name: 'Menus',
        component: RoutesAlias.Menu,
        meta: {
          title: 'menus.system.menu',
          keepAlive: true,
          roles: ['R_SUPER'],
          authList: [
            {
              title: '新增',
              authMark: 'add'
            },
            {
              title: '编辑',
              authMark: 'edit'
            },
            {
              title: '删除',
              authMark: 'delete'
            }
          ]
        }
      },
      {
        path: 'operation-log',
        name: 'OperationLog',
        component: RoutesAlias.OperationLog,
        meta: {
          title: 'menus.system.operationLog',
          keepAlive: true,
          roles: ['R_SUPER', 'R_ADMIN']
        }
      },
      {
        path: 'login-log',
        name: 'LoginLog',
        component: RoutesAlias.LoginLog,
        meta: {
          title: 'menus.system.loginLog',
          keepAlive: true,
          roles: ['R_SUPER', 'R_ADMIN']
        }
      }
    ]
  },
  {
    path: '/area',
    name: 'Area',
    component: RoutesAlias.Layout,
    meta: {
      title: 'menus.area.title',
      icon: '&#xe715;'
    },
    children: [
      {
        path: 'areaIndex',
        name: 'AreaIndex',
        component: RoutesAlias.AreaIndex,
        meta: {
          title: 'menus.area.index',
          keepAlive: true,
          roles: ['R_SUPER'],
          authList: [
            {
              title: '新增',
              authMark: 'add'
            },
            {
              title: '编辑',
              authMark: 'edit'
            },
            {
              title: '删除',
              authMark: 'delete'
            },
            {
              title: '查看',
              authMark: 'view'
            }
          ]
        }
      },
      {
        path: 'areaDetail',
        name: 'AreaDetail',
        component: RoutesAlias.AreaDetail,
        meta: {
          title: '小区详情',
          keepAlive: true,
          isHide: true
        }
      }
    ]
  },
  {
    path: '/actManage',
    name: 'actManage',
    component: RoutesAlias.Layout,
    meta: {
      title: 'menus.actManage.title',
      icon: '&#xe715;'
    },
    children: [
      {
        path: 'actIndex',
        name: 'actIndex',
        component: RoutesAlias.actIndex,
        meta: {
          title: 'menus.actManage.index',
          keepAlive: true,
          roles: ['R_SUPER'],
          authList: [
            {
              title: '新增',
              authMark: 'add'
            },
            {
              title: '编辑',
              authMark: 'edit'
            },
            {
              title: '删除',
              authMark: 'delete'
            },
            {
              title: '查看',
              authMark: 'view'
            }
          ]
        }
      },
      {
        path: '/actDetail',
        name: 'actDetail',
        component: RoutesAlias.actDetail,
        meta: {
          roles: ['R_SUPER'],
          hidden: true,
          isHide: true
        }
      }
    ]
  },
  {
    path: '/postStation',
    name: 'PostStation',
    component: RoutesAlias.Layout,
    meta: {
      title: 'menus.postStation.title',
      icon: '&#xe7b8;'
    },
    children: [
      {
        path: 'postStationIndex',
        name: 'PostStationIndex',
        component: RoutesAlias.PostStationIndex,
        meta: {
          title: 'menus.postStation.index',
          keepAlive: true,
          roles: ['R_SUPER', 'R_ADMIN'],
          authList: [
            {
              title: '新增',
              authMark: 'add'
            },
            {
              title: '编辑',
              authMark: 'edit'
            },
            {
              title: '删除',
              authMark: 'delete'
            },
            {
              title: '查看',
              authMark: 'view'
            }
          ]
        }
      }
    ]
  },
  {
    path: '/ticket',
    name: 'Ticket',
    component: RoutesAlias.Layout,
    meta: {
      title: 'menus.ticket.title',
      icon: '&#xe7bc;'
    },
    children: [
      {
        path: 'TicketIndex',
        name: 'TicketIndex',
        component: RoutesAlias.TicketIndex,
        meta: {
          title: 'menus.ticket.index',
          keepAlive: true,
          roles: ['R_SUPER', 'R_ADMIN'],
          authList: [
            {
              title: '新增',
              authMark: 'add'
            },
            {
              title: '编辑',
              authMark: 'edit'
            },
            {
              title: '删除',
              authMark: 'delete'
            },
            {
              title: '查看',
              authMark: 'view'
            }
          ]
        }
      },

      {
        path: 'ticketType',
        name: 'TicketType',
        component: RoutesAlias.TicketType,
        meta: {
          title: 'menus.TicketType.title',
          keepAlive: false,
          roles: ['R_SUPER', 'R_ADMIN'],
          authList: [
            // 按需配置 ticketType 的操作权限
            { title: '新增', authMark: 'add' },
            { title: '编辑', authMark: 'edit' },
            { title: '删除', authMark: 'delete' },
            { title: '查看', authMark: 'view' }
          ]
        }
      }
    ]
  },
  {
    path: '/help',
    name: 'Help',
    component: RoutesAlias.Layout,
    meta: {
      title: 'menus.help.title',
      icon: '&#xe7bc;'
    },
    children: [
      {
        path: 'HelpRecord',
        name: 'HelpRecord',
        component: RoutesAlias.HelpRecord,
        meta: {
          title: 'menus.help.record',
          keepAlive: true,
          roles: ['R_SUPER', 'R_ADMIN'],
          authList: [
            {
              title: '新增',
              authMark: 'add'
            },
            {
              title: '编辑',
              authMark: 'edit'
            },
            {
              title: '删除',
              authMark: 'delete'
            },
            {
              title: '查看',
              authMark: 'view'
            }
          ]
        }
      }
    ]
  },
  {
    path: '/result',
    name: 'Result',
    component: RoutesAlias.Layout,
    meta: {
      title: 'menus.result.title',
      icon: '&#xe715;'
    },
    children: [
      {
        path: 'success',
        name: 'ResultSuccess',
        component: RoutesAlias.Success,
        meta: {
          title: 'menus.result.success',
          keepAlive: true
        }
      },
      {
        path: 'fail',
        name: 'ResultFail',
        component: RoutesAlias.Fail,
        meta: {
          title: 'menus.result.fail',
          keepAlive: true
        }
      }
    ]
  },
  {
    path: '/exception',
    name: 'Exception',
    component: RoutesAlias.Layout,
    meta: {
      title: 'menus.exception.title',
      icon: '&#xe820;'
    },
    children: [
      {
        path: '403',
        name: '403',
        component: RoutesAlias.Exception403,
        meta: {
          title: 'menus.exception.forbidden',
          keepAlive: true
        }
      },
      {
        path: '404',
        name: '404',
        component: RoutesAlias.Exception404,
        meta: {
          title: 'menus.exception.notFound',
          keepAlive: true
        }
      },
      {
        path: '500',
        name: '500',
        component: RoutesAlias.Exception500,
        meta: {
          title: 'menus.exception.serverError',
          keepAlive: true
        }
      }
    ]
  },
  {
    path: '/userarea',
    name: 'UserArea',
    component: RoutesAlias.Layout,
    meta: {
      title: 'menus.userArea.title',
      icon: '&#xe715;'
    },
    children: [
      {
        path: 'userarea',
        name: 'UserareaList',
        component: RoutesAlias.Userarea,
        meta: {
          title: 'menus.userArea.list',
          keepAlive: true
        }
      }
    ]
  },
  {
    path: '/newEmployment',
    name: 'NewEmployment',
    component: RoutesAlias.Layout,
    meta: {
      title: 'menus.newEmployment.title',
      icon: '&#xe715;'
    },
    children: [
      {
        path: 'index',
        name: 'NewEmploymentIndex',
        component: RoutesAlias.NewEmploymentIndex,
        meta: {
          title: 'menus.newEmployment.index',
          keepAlive: true,
          roles: ['R_SUPER', 'R_ADMIN'],
          authList: [
            {
              title: '新增',
              authMark: 'add'
            },
            {
              title: '编辑',
              authMark: 'edit'
            },
            {
              title: '删除',
              authMark: 'delete'
            },
            {
              title: '查看',
              authMark: 'view'
            }
          ]
        }
      }
    ]
  },
  {
    path: '/authenticatedPersonnel',
    name: 'AuthenticatedPersonnel',
    component: RoutesAlias.Layout,
    meta: {
      title: 'menus.authenticatedPersonnel.title',
      icon: '&#xe715;'
    },
    children: [
      {
        path: 'index',
        name: 'AuthenticatedPersonnelIndex',
        component: RoutesAlias.AuthenticatedPersonnelIndex,
        meta: {
          title: 'menus.authenticatedPersonnel.index',
          keepAlive: true,
          roles: ['R_SUPER', 'R_ADMIN'],
          authList: [
            {
              title: '新增',
              authMark: 'add'
            },
            {
              title: '编辑',
              authMark: 'edit'
            },
            {
              title: '删除',
              authMark: 'delete'
            },
            {
              title: '查看',
              authMark: 'view'
            },
            {
              title: '核实',
              authMark: 'check'
            },
            {
              title: '导入',
              authMark: 'import'
            },
            {
              title: '导出',
              authMark: 'export'
            }
          ]
        }
      }
    ]
  },
  {
    path: '/integralGoodsMall',
    name: 'IntegralGoodsMall',
    component: RoutesAlias.Layout,
    meta: {
      title: 'menus.integralGoodsMall.title',
      icon: '&#xe73d;'
    },
    children: [
      {
        path: 'integralGoods',
        name: 'IntegralGoods',
        component: RoutesAlias.IntegralGoods,
        meta: {
          title: 'menus.integralGoodsMall.integralGoods',
          keepAlive: true,
          roles: ['R_SUPER'],
          authList: [
            { title: '新增', authMark: 'add' },
            { title: '编辑', authMark: 'edit' },
            { title: '删除', authMark: 'delete' },
            { title: '查看', authMark: 'view' }
          ]
        }
      },
      {
        path: 'exchangeIntegralGoods',
        name: 'ExchangeIntegralGoods',
        component: RoutesAlias.ExchangeIntegralGoods,
        meta: {
          title: 'menus.integralGoodsMall.exchangeIntegralGoods',
          keepAlive: true,
          roles: ['R_SUPER'],
          authList: [
            { title: '新增', authMark: 'add' },
            { title: '编辑', authMark: 'edit' },
            { title: '删除', authMark: 'delete' },
            { title: '查看', authMark: 'view' }
          ]
        }
      },
      {
        path: 'redemptionHistory',
        name: 'RedemptionHistory',
        component: RoutesAlias.RedemptionHistory,
        meta: {
          title: 'menus.integralGoodsMall.redemptionHistory',
          keepAlive: true,
          roles: ['R_SUPER'],
          authList: [
            { title: '新增', authMark: 'add' },
            { title: '编辑', authMark: 'edit' },
            { title: '删除', authMark: 'delete' },
            { title: '查看', authMark: 'view' }
          ]
        }
      },
      {
        path: '/stationDetail',
        name: 'stationDetail',
        component: RoutesAlias.stationDetail,
        meta: {
          title: '兑换点详情',
          roles: ['R_SUPER'],
          hidden: true,
          isHide: true
        }
      }
    ]
  }
]
